package view;
import javax.swing.*;
import java.awt.*;

/**
 * This class handles a custom cell render for
 * the JList (the player list)
 * as shown in the oracle javadoc *  
 * 
 * @author Thomas
 *
 */
class PlayerListCellRenderer extends JLabel implements ListCellRenderer 
{
	  private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);

	  public PlayerListCellRenderer() 
	  {
	    setOpaque(true);
	    setIconTextGap(12);
	  }

	  public Component getListCellRendererComponent(JList list, Object value,
	      int index, boolean isSelected, boolean cellHasFocus) 
	  {
		  JLabel entry = (JLabel) value;
	 
	    if (isSelected) 
	    {
	      setBackground(HIGHLIGHT_COLOR);
	      setForeground(Color.white);
	    } 
	    else 
	    {
	      setBackground(Color.white);
	      setForeground(Color.black);
	    }
	    return entry;
	  }
	}
